
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_DATO_NOTAT]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[EBAS_DATO_NOTAT]
GO

CREATE TABLE [dbo].[EBAS_DATO_NOTAT] (
	[GUID] [uniqueidentifier] ROWGUIDCOL NOT NULL ,
	[DATO] [datetime] NOT NULL ,
	[EMNE] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL ,
	[FIL_NAVN] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NOT NULL ,
	[NOTAT_BINARY] [image] NULL ,
	[STUDERENDE_GUID] [uniqueidentifier] NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[EBAS_DATO_NOTAT] WITH NOCHECK ADD 
	CONSTRAINT [PK_DATO_NOTAT] PRIMARY KEY  CLUSTERED 
	(
		[GUID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[EBAS_DATO_NOTAT] ADD 
	CONSTRAINT [DF_EBAS_DATO_NOTAT_DATO] DEFAULT (getdate()) FOR [DATO],
	CONSTRAINT [FK_EBAS_DATO_NOTAT_EBAS_STUDERENDE] FOREIGN KEY 
	(
		[STUDERENDE_GUID]
	) REFERENCES [dbo].[EBAS_STUDERENDE] (
		[GUID]
	)
GO
